home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 131 / XENIATGM131.iso / Shareware / openOffice.org 641 / Windows / f_0202 / Common.xba < prev    next >
Extensible Markup Language  |  2001-08-02  |  4KB  |  131 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Common" script:language="StarBasic">REM  *****  BASIC  *****
  4. Option Explicit
  5.  
  6. Function LoadNewStyles(oDocument as Object, oDialogModel as Object, CurIndex as Integer, SourceFile as String, Styles() as String, TextureDir as String) as Boolean
  7. Dim BackGroundURL as String
  8. Dim oBackGraph as Object
  9. Dim i, BackColor as Long
  10. Dim bLocWithBackGraphic as Boolean
  11. Dim oFamilies as Object, oFamily as Object', oStyle as Object
  12. Dim StylesOptions(0) as New com.sun.star.beans.PropertyValue
  13.  
  14.     If SourceFile <> "" Then
  15.         StylesOptions(0).Name = "OverwriteStyles"
  16.         StylesOptions(0).Value = True
  17.         oDocument.StyleFamilies.LoadStylesFromURL(SourceFile, StylesOptions())
  18.     End If
  19.  
  20.     ' Read array fields for background, bullet & graphics
  21.     BackgroundURL = Styles(7, CurIndex)
  22.     If Left(BackgroundURL, 1) <> "#" Then
  23.         BackgroundURL = TextureDir + BackgroundURL
  24.         bLocWithBackGraphic = True
  25.     Else
  26.         BackColor = clng("&H" & Right(BackgroundURL, Len(BackgroundURL)-1))
  27.         bLocWithBackGraphic = False
  28.     End If
  29.     oFamilies = oDocument.StyleFamilies
  30.     oFamily = oFamilies.GetbyName("PageStyles")
  31.     For i = 0 To oFamily.Count - 1
  32.         If oFamily.GetByIndex(i).IsInUse Then
  33.             oStyle = oFamily.GetbyIndex(i)
  34.             If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then
  35.                 If Left(BackgroundURL, 1) = "#" Then
  36.                     oStyle.BackGraphicURL = ""
  37.                     oStyle.BackColor = BackColor
  38.                     oStyle.BackTransparent = False
  39.                 Else
  40.                     oStyle.BackGraphicUrl = BackGroundURL
  41.                     SetTileBackgroundorNot(oDialogModel, oStyle)
  42.                 End If
  43.             End If
  44.         End If
  45.     Next i
  46.     LoadNewStyles() = bLocWithBackGraphic
  47. ErrorOcurred:
  48.     If Err <> 0 Then
  49.         MsgBox (WebWiz_gErrWhileLoadStyles$, 16, WebWiz_gWizardName$)
  50.         CancelHTMLWizard()
  51.     End If
  52. End Function
  53.  
  54.  
  55.  
  56. Sub ChangeBackGraphicUrl(SavePath as String)
  57. Dim oPageFamily as Object
  58. Dim i as Integer
  59.     oPageFamily = oBaseDocument.StyleFamilies.GetbyName("PageStyles")
  60.     For i = 0 To oPageFamily.Count - 1
  61.         If oPageFamily.GetByIndex(i).IsInUse Then
  62.             oStyle = oPageFamily.GetbyIndex(i)
  63.             If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then
  64.                 If oStyle.BackGraphicUrl <> "" Then
  65.                     oStyleBack.GraphicUrl = CopyFile(oStyle.BackGraphicUrl, SavePath)
  66.                     Exit Sub
  67.                 End If
  68.             End If
  69.         End If
  70.     Next i
  71. End Sub
  72.  
  73.  
  74. Sub SetBackGraphicStyle(oEvent as Object)
  75. Dim oFamilies as Object
  76. Dim oFamily as Object
  77. Dim i as Integer
  78. Dim oOptModel as Object
  79. Dim iBackgroundValue as Integer
  80. Dim oLocDocument as Object
  81.     ooptModel = oEvent.Source.Model
  82.     iBackgroundValue = Val(ooptModel.Tag)
  83.     oLocDocument = StarDesktop.ActiveFrame.Controller.Model
  84.     oLocDocument.LockControllers
  85.     oFamilies = oLocDocument.StyleFamilies
  86.     oFamily = oFamilies.GetbyName("PageStyles")
  87.     For i = 0 To oFamily.Count - 1
  88.         If oFamily.GetByIndex(i).IsInUse Then
  89.             oStyle = oFamily.GetbyIndex(i)
  90.             If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then
  91.                 oStyle.BackGraphicLocation = iBackgroundValue
  92.             End If
  93.         End If
  94.     Next i
  95.     oLocDocument.UnlockControllers
  96. End Sub
  97.  
  98.  
  99. Sub SetTileBackgroundorNot(DialogModel as Object, oStyle as Object)
  100.       If DialogModel.optTiled.State = 1 Then
  101.         oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.TILED
  102.       Else
  103.         oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.AREA
  104.       End If
  105. End Sub
  106.  
  107.  
  108. Sub    ToggleOptionButtons(DialogModel as Object, bDoEnable as Integer)
  109.     DialogModel.optTiled.Enabled = bDoEnable
  110.     DialogModel.optArea.Enabled = bDoEnable
  111.     DialogModel.hlnBackground.Enabled = bDoEnable
  112. End Sub
  113.  
  114.  
  115. Function GetCurIndex(oListbox as Object, sList() as String, MaxIndex as Integer, FileIndex as Integer)
  116. Dim i, n as Integer
  117. Dim SelValue as String
  118.     ' Get selected list entry
  119.     n = oListbox.SelectedItems(0)
  120.     SelValue = oListbox.StringItemList(n)
  121.     ' Find field index for chosen list entry
  122.     For i = 0 To MaxIndex
  123.         If sList(1, i) = SelValue Then
  124.             FileStr = sList(FileIndex, i)
  125.             Exit For
  126.         End If
  127.     Next
  128.     GetCurIndex = i
  129. End Function
  130.  
  131. </script:module>